#!/bin/bash  
mysql -uroot -proot -hhadoop3<<EOF  
use result;

DELETE FROM res_vipGap where vipGap='0';
DELETE FROM res_vipGap_cd where vipGap='0';

REPLACE INTO result.res_oil_month
SELECT SUBSTR(minutes , 1 , 7) month,stationID,SUM(oilNumber),SUM(oilLitre),SUM(oilMoney) from res_oil 
where minutes>'2018' GROUP BY SUBSTR(minutes , 1 , 7),stationID;

REPLACE INTO result.res_notoil_month
SELECT SUBSTR(minutes , 1 , 7) month,stationID,SUM(notoilNumber),SUM(notoilMoney) from res_notoil
where minutes>'2018' GROUP BY SUBSTR(minutes , 1 , 7),stationID;
EOF
exit;
